/*
 * @FilePath: Fire.js
 * @Author: 杜芬
 * @Date: 2024-05-08 17:07:55
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2024-05-12 18:45:46
 * Copyright: 2024 xxxTech CO.,LTD. All Rights Reserved.
 * @Descripttion: 页面
 */
// 火灾标记类
import * as THREE from 'three'

export class Fire {
  constructor(scene, center, size) {
    this.scene = scene
    this.center = center  // 建筑物中心点三维向量对象
    this.size = size  // 建筑物大小的三维向量对象

    this.init()
  }
  // 初始化火灾标记
  init () {
    const texture = new THREE.TextureLoader().load('icon/fire.png')
    texture.colorSpace = THREE.SRGBColorSpace
    const spriteMaterial = new THREE.SpriteMaterial({
      map:texture
    })
   const sprite = new THREE.Sprite(spriteMaterial)
   // +3 让精灵物体的中心点不在建筑物顶点，再往上移动一些单位
   sprite.position.set(this.center.x, this.center.y + this.size.y / 2 + 5, this.center.z)
   sprite.scale.set(10,10,10)
   this.scene.add(sprite)

   this.model = sprite
  }
// 移除指定物体
  clear() {
    this.scene.remove(this.model)
  }
}